//实现平滑滚动要用到的代码，因为display:none;会使元素消失，无法滚动。所以要通过改变元素的高度来实现平滑滚动

//——————————————————————————————————————————导航栏————————————————————————————————————
document.getElementById('back-link').addEventListener('click', function () {
    window.location.hash = '/';
});
let open = false;

function nav() {
    if (open) {
        document.getElementById("mySidenav").style.width = "0";
        document.getElementById("main").style.marginLeft = "0";
        open = false;
    } else {
        document.getElementById("mySidenav").style.width = "250px";
        document.getElementById("main").style.marginLeft = "250px";
        open = true;
    }
}

function openNav() {
    document.getElementById("mySidenav").style.width = "250px";
    document.getElementById("main").style.marginLeft = "250px";
}

function closeNav() {
    document.getElementById("mySidenav").style.width = "0";
    document.getElementById("main").style.marginLeft = "0";
}

//——————————————————————————————————————————下拉菜单————————————————————————————————————
document.getElementById('dropdownMenuLink').addEventListener('click', function (event) {
    event.preventDefault();
    var dropdownMenu = document.getElementById('dropdownMenu');
    if (dropdownMenu.style.maxHeight === '0px') {
        dropdownMenu.style.maxHeight = '200px';  // 你可以根据需要调整这个值
    } else {
        dropdownMenu.style.maxHeight = '0px';
    }
});